package com.yotoodesign.dianba.util;

import java.util.concurrent.atomic.AtomicInteger;

import com.yotoodesign.dianba.R;

import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.widget.ImageView;

public class GuidePageChangeListener implements OnPageChangeListener{
	private ImageView[] imgFocuses;
	private AtomicInteger what;
	
	public GuidePageChangeListener(ImageView[] imgFocuses,AtomicInteger what){
		this.imgFocuses = imgFocuses;
		this.what = what;
	}
	
	@Override
	public void onPageScrollStateChanged(int arg0) {

	}

	@Override
	public void onPageScrolled(int arg0, float arg1, int arg2) {

	}

	@Override
	public void onPageSelected(int arg0) {
		what.getAndSet(arg0);
		for (int i = 0; i < imgFocuses.length; i++) {
			imgFocuses[arg0]
					.setBackgroundResource(R.drawable.banner_dian_focus);
			if (arg0 != i) {
				imgFocuses[i]
						.setBackgroundResource(R.drawable.banner_dian_blur);
			}
		}

	}
}
